
$.ajax({
  url: "json/cart.json",
  type: 'get',
  //预期返回的数据类型
  dataType: 'json',
  //成功返回回调函数
  success: function (data) {
    for (let i = 0; i < data.length; i++) {
      //数组中的某项数据
      let temp = i;
      let item = data[i];
      // let item= i;
      $(".ttt").append(`
              <li onmouseenter="showBtn(this)"  data-index="${temp}" onmouseleave="hiddeBtn(this)" class="yyy">
                  <img src="${item.img1}" class="t">
      
                  <p class="ys2 cent">${item.p}</p>
                  <span class="bj_ys_zt">${item.span1}</span>
                  <span class="faho_bj_zt">${item.span2}</span>
                  <div class="foot_jiag">
                      <img src="${item.img2}" class="imageA">
                      <span class="ys_hui">${item.span3}</span>
                  </div>
                  <div class="foot_d">
                      <span class="ys_hui2">${item.span4}</span>
                      <span class="jl">${item.span5}</span>
                  </div>
                  <input type="submit" value="添加" class="btn5">
                </li>
      `)
    }
  }
});

function showBtn(thisobj) {
 
      var table = document.createElement("table")
  
    // var tr = document.createElement("tr");
  let image = thisobj.parentNode.children[0].src;
  let name = thisobj.children[1].innerText;
  let imageA = document.querySelector(".imageA").src;

  let good = {
    image:image,
    name:name,
    anotherimg:imageA
  }
  
  console.log(good);

  localStorage.setItem("good",JSON.stringify(good));
 

}
function showBtn(thisobj){
  let btn5 = $('.btn5');
  // let index = $(this)
  // console.log(index);
  btn5.css("display","block");
}

function hiddeBtn(thisobj){
  let btn5 = $('.btn5');
  btn5.css("display","none");
}